<?
/**
 *
 * @package izz.xml
 * @author Binzy Wu
 * @version 0.1.0 init and fished
 *
 */

// $Id: XmlChildEnumerator.php,v 1.1.1.1 2005/03/03 04:53:22 icer Exp $

require_once(dirname(__FILE__)."/XmlNode.php");
import("izz.collection.IEnumerator");

/*
 * @package izz.xml
 * @access protected
 */
class XmlChildEnumerator extends IEnumerator
{

	var $child;
	var $isFirst;
	var $container;

	function XmlChildEnumerator($xmlnode)
	{
		//
		$this->container = $xmlnode;
		$this->child = $xmlnode->getFirstChild();
		$this->isFirst = true;
	}
	//
	function getCurrent()
	{
      if ($this->isFirst || ($this->child == null))
      {
			trigger_error("XmlChildEnumerator::getCurrent: xml operate error!", E_USER_ERROR);
      }
      return this.child;
	}

	function reset()
	{
		$this->isFirst = true;
		$this->child = $this->container->getFirstChild();
	}

	/**
	 *
	 * @return boolean 
	 */
	function moveNext()
	{
      if ($this->isFirst)
      {
            $this->child = $this->container->getFirstChild();
            $this->isFirst = false;
      }
      else if ($this->child != null)
      {
            $this->child = $this->child->getNextSibling();
      }
      return ($this->child != null);

	}


}

?>